﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using TransFormer.BLL;

namespace TransFormer.Web
{
    public partial class Master2 : System.Web.UI.MasterPage
    {
        private readonly BLL.Clients _bllClients = new BLL.Clients();
        private readonly BLL.KeyWords _bllKey = new KeyWords();

        protected void Page_Load(object sender, EventArgs e)
        {
            var model = _bllKey.GetModelList(string.Empty).FirstOrDefault();
            if (model != null)
            {
                HtmlMeta keywords = new HtmlMeta();
                keywords.Name = "keywords";
                keywords.Content = model.KeyContent;
                Page.Header.Controls.Add(keywords);
            }
        }

        protected void LiuYan(object sender, EventArgs e)
        {
            if (!Page.IsValid) return;
            var rateText = ctl00_csMainRegion_csContentRegion_MainArea_ToolboxControl_RateThisPage2_TextBoxMessage.Value;
            var emailText = ctl00_csMainRegion_csContentRegion_MainArea_ToolboxControl_RateThisPage2_TextBoxFrom.Value;
            if (string.IsNullOrEmpty(emailText) || string.IsNullOrEmpty(rateText)) return;
            _bllClients.Add(new Model.Clients()
            {
                Date = DateTime.Now,
                Email = emailText,
                IsReaded = false,
                Message = rateText
            });


        }
    }
}